﻿

namespace Gp.Scripts.Core
{
    public class GameStateSkillSelect : GameState
    {
        private BaseUnit _unit;
        private SkillEntity _skillEntity;

        private GameState _lastState;
        
        public GameStateSkillSelect(SkillEntity skillEntity)
        {
            _skillEntity = skillEntity;
        }
        

        protected override void OnStateEnter(GameState lastState)
        {
            _lastState = lastState;
            RegisterEvent<Event_SkillUI.Cancel>(args =>
            {
                // 尝试回到上一个状态
                this.SwitchState(_lastState ?? new GameStateNoBattle());
            });
            
            _skillEntity.Display();
        }

        
        protected override void OnStateExit(GameState nextState)
        {
            _skillEntity.CleanUp();
        }
    }
}